#include <iostream>
#include <algorithm>
#define MAX 101
using namespace std;
int D[MAX][MAX];
int n;

int main()
{
	int* maxSum;
	int i,j;
	cin >> n;
	for(int i=1;i<=n;++i)
		for(int j=1;j<=i;++j)
			cin>>D[i][j];
	maxSum = D[n];
	for(int i=n-1;i>=1;--i)
		for(int j=1;j<=i;++j)
			maxSum[j] = max(maxSum[j], maxSum[j+1])+D[i][j];
	cout << maxSum[1] << endl;
	return 0;
}


int main2()
{
	int maxSum[MAX][MAX];
	int i,j;
	cin >> n;
	for(int i=1;i<=n;++i)
		for(int j=1;j<=i;++j)
			cin>>D[i][j];
	for(int i=1;i<=n;++i)
		maxSum[n][i] = D[n][i];
	for(int i=n-1;i>=1;--i)
		for(int j=1;j<=i;++j)
			maxSum[i][j] = max(maxSum[i+1][j], maxSum[i+1][j+1])+D[i][j];
	cout << maxSum[1][1] << endl;
	return 0;
}